package org.czl.leetcode4;

public class l2222 {
    public static void main(String[] args) {
        System.out.println(numberOfWays("010"));
    }
    public static long numberOfWays(String s) {
        char[] chars = s.toCharArray();
        char[] char1 = {'0','1','0'};
        char[] char2 = {'1','0','1'};

        return help(chars,char1)+help(chars,char2);
    }
    public static long help(char[] chars,char[] goal){
        long a=0,b=0,c=0;
        for(int i=0;i<chars.length; i++){
            if (chars[i] == goal[0]) a++;
            if (chars[i] == goal[1]) b +=a;
            if (chars[i] == goal[2]) c +=b;
        }
        return c;
    }
}
